<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once APPPATH . 'models/m_select.php';

/**
 * Модель выборки изображений
 *
 * @package CoreFramework
 * @version 1.0
 * @author Gennadiy Kozlenko
 */
class M_Select_Images extends M_Select {
   
   /**
    * Конструктор класса
    *
    * @access public
    * @return M_Select_Images
    */
   function M_Select_Images() {
      parent::M_Select();
      $this->load->language('select_images');
      // Устанавливаем запрос
      $sql = "
         SELECT
            id_image AS id,
            '' AS preview,
            title,
            image AS image_hidden
         FROM
            " . $this->db->dbprefix('images') . "
      ";
      parent::set_sql($sql);
   } // end M_Select_Images
   
   /**
    * Установка SQL запроса
    *
    * @access public
    * @param string $table
    */
   function set_sql($sql) {
      
   } // end set_sql
   
   /**
    * Обработка результата
    *
    * @access protected
    * @param array $result
    */
   function _process_result(&$result) {
      $result['preview'] = str_replace(array('{%id%}', '{%image%}'), array($result['id'], $result['image_hidden']), $this->lang->line('images_preview'));
      $this->_fields['preview']['sort'] = false; 
   } // end _process_result
   
}
